<?php
namespace app\manage\model;
use think\Model;
use think\Session;
class Logins extends Model
{
	protected $resultSetType = 'collection';
    public function login($account,$root){
        $db = db('user')->where('account',$account)->find();
        if($db){
            if($db['ismanage']==1){
                if($db['root']==md5($root.$db['randomcode'])){
                    Session::set('user',$db['account']);
                    Session::set('userid',$db['id']);
                    Session::set('name',$db['name']);
                    return 1;
                }
                else{
                    return 3;
                }
            }else{
                return 2;
            }
        }
        else{
            return 4;
        }
    }

}